const Singleton = (function () {
  var instance;

  function privateSetName(a) {
    console.log(a + ".setName");
  }
  function Init() {
    console.log("实例化init");
  }
  Init.prototype.setName = privateSetName;

  return {
    getInstance: () => {
      if (!instance) {
        instance = new Init();
      }
      return instance;
    },
  };
})();

// 多次实例化只会创建一次，之后都会直接返回第一次的引用
const $ = Singleton.getInstance();
const $1 = Singleton.getInstance();
const $2 = Singleton.getInstance();
$.setName("$");
$1.setName("$1");
$2.setName("$2");
